package cn.etg.product2503.mapper;

import cn.etg.product2503.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

public interface ProductMapper {
    @Insert("insert into product (name, description, price, stock, create_time, update_time) " +
            "values (#{name}, #{description}, #{price}, #{stock}, now(), now())")
    void insert(Product product);
    @Select("select * from product where name = #{name}")
    Product selectByName(String name);
    @Delete("delete from product where id = #{id}")
    void deleteById(Long id);
    @Update("update product set name = #{name}, description = #{description}, " +
            "price = #{price}, stock = #{stock}, update_time = now() where id = #{id}")
    void updateById( Product product);

    List<Product> queryProduct(String keyword);
}
